package com.orangelife.mobile.common.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.curry.android.view.recyclerView.YfListAdapter;
import com.curry.orangelife.mobile.R;

import java.util.List;


/**
 * Created by yefeng on 8/5/15.
 * github:yefengfreedom
 */
public abstract class SimpleAdapter<T> extends YfListAdapter<T> {

    public SimpleAdapter(List<T> data) {
        super(data);
    }

    @Override
    public RecyclerView.ViewHolder onCreateFooterViewHolder(ViewGroup parent) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_footer1, parent, false);
        return new FooterViewHolder(view,mFooters);
    }

    @Override
    public RecyclerView.ViewHolder onCreateDataViewHolder(ViewGroup parent) {
        return null;
    }

    private static final class FooterViewHolder extends RecyclerView.ViewHolder {

        TextView mText;

        public FooterViewHolder(View itemView,List<Object> mFooters) {
            super(itemView);
            mText = (TextView) itemView.findViewById(R.id.tv_footer);
            mText.setText(mFooters.get(0).toString());
        }
    }

    @Override
    protected RecyclerView.ViewHolder onCreateEmptyViewHolder(ViewGroup parent) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_no_bill,null);
        EmptyViewHolder viewHolder= new EmptyViewHolder(view);
        viewHolder.mText.setText("暂无信息！");
        return viewHolder;
    }

    class EmptyViewHolder extends RecyclerView.ViewHolder{
        TextView mText;
        public EmptyViewHolder(View itemView) {
            super(itemView);
            mText = (TextView)itemView.findViewById(R.id.tvNoBill);
        }
    }
}
